package demo.day10

// Kotlin 定义泛型
fun main() {
    val student1 = Student("Kiki", 18, 'M')
    val student2 = Student("QiQi", 18, 'W')
    val teacher1 = Teacher("JiJi", 28, 'M')
    val teacher2 = Teacher("Oooo", 28, 'W')

    KtBase02(student1).show()
    KtBase02(student2).show()
    KtBase02(teacher1).show()
    KtBase02(teacher2).show()
    // 无论传入什么类型都没关系
    KtBase02(String("123".toByteArray())).show()
    KtBase02(12343131).show()
}


// 万能输出器
class KtBase02<T>(private val obj: T) {
    fun show() = println("万能输出器${obj}")
}

data class Student(val name: String, val age: Int, val sex: Char)
data class Teacher(val name: String, val age: Int, val sex: Char)




